<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  {include="user/style"}
  <title>资料与账号 - 个人中心</title>
</head>
<body>

{include="user/top"}

<div class="login-page page">
  <div class="container clearfix">
    {include="user/left_nav"}
    <div class="user-right">
      <div class="user-tips">
        <p><i class="iconfont iconxiaoxi3"></i> 欢迎注册本站会员，注册会员后您将享受专属会员服务!包括但不限于专属文章浏览权限，会员投稿权限，在线购物权限，下载会员可见附件等实用功能，欢迎注册体验！</p>
      </div>
      <div class="user-content">
        <h2>资料与账号</h2>
        <form action="" method="POST" onsubmit="checkform()" id="jizhiform" class="user-form">
          <div class="form-control">
            <label for="">头像：</label>
              <span class="view_img">{if($member['litpic'])}<img src="{$member['litpic']}" height="100" style="border-radius: 50%;" />{/if}</span><br/>
              <input name="litpic" type="hidden" id="fileurl" value="{$member['litpic']}" /><br/>
              <input type="file" class="btn btn-primary rounded btn-block" name="file" id="fileid">
          </div>
          <div class="form-control">
            <label for="">昵称：</label>
            <input type="text" value="{$member['username']}" id="t_username" name="username" placeholder="请输入您的昵称">
          </div>
          <div class="form-control">
            <label for="">手机：</label>
            <input type="tel" value="{$member['tel']}" name="tel" id="t_tel" placeholder="请输入您的手机号">
          </div>
          <div class="form-control">
            <label for="">邮箱：</label>
            <input type="email" value="{$member['email']}" name="email" name="t_email" placeholder="请输入您的邮箱">
          </div>
          <div class="form-control">
            <label for="">性别：</label>
            <div class="check-box"><input type="radio" name="sex" value="1" {if($member['sex']==1)}checked{/if}>男 <input type="radio" name="sex" value="2" {if($member['sex']==2)}checked{/if}>女 <input type="radio" name="sex" value="0" {if($member['sex']==0)}checked{/if}>不展示</div>
          </div>
          <div class="form-control">
            <label for="">省份：</label>
            <input type="text" value="{$member['province']}" name="province" name="t_province" placeholder="可不填">
          </div>
		  <div class="form-control">
            <label for="">城市：</label>
            <input type="text" value="{$member['city']}" name="city" name="t_city" placeholder="可不填">
          </div>
		  <div class="form-control">
            <label for="">详细地址：</label>
            <input type="text" value="{$member['address']}" name="address" name="t_address" placeholder="可不填">
          </div>
          <div class="form-control">
            <label for="password">新密码：</label>
            <div class="form-password">
              <input type="password" class="password1" name="password" id="t_password" value="" placeholder="如果不修改，请留空">
              <i class="iconfont iconyanjing"></i><i class="iconfont iconyanjing-guan"></i>
            </div>
          </div>
          <div class="form-control">
            <span><label for="setpassword">确认密码：</label></span>
            <div class="form-password">
              <input type="password" class="password1" name="repassword" id="t_repassword" value="" placeholder="如果不修改，请留空">
              <i class="iconfont iconyanjing"></i><i class="iconfont iconyanjing-guan"></i>
            </div>
          </div>
		  <div class="form-control">
            <label for="">邀请链接：</label>
            <input type="text" value="{fun U('login/register')}?invite={$member['id']}" readonly name="invite" id="t_invite" placeholder="邀请链接">
          </div>
          <div class="form-control">
            <span><label for="">个性签名：</label></span>
            <textarea name="signature" id="signature" placeholder="请输入您的个性签名">{$member['signature']}</textarea>
          </div>
          <span id="fields_ext"></span>
          <div class="form-control">
            <label for="submit"></label>
            <input type="submit" name="submit" value="提交">
          </div>
        </form>
      </div>
    </div>
  </div>
</div>

{include="user/footer"}
<script type="text/javascript">
function get_fields(tid,id){
    var id = arguments[1]?arguments[1]:0;
    $.post("{fun U('common/get_fields')}",{molds:'member',tid:tid,id:id},function(res){
      if(res.code==0){
        //默认 res.tpl输出的是layui的模板HTML,可以审核元素查看res里面的内容
        //$("#ext_fields").html(res.tpl);
        var html = '';
        var len = res.fields_list.length;
        if(len>0){
          //根据对应的字段，进行HTML设计
          for(var i=0;i<len;i++){
            
          }
          
        }
        $("#fields_ext").html(res.tpl);
      }
      
    },'json');
  }
$(function(){
  get_fields(0,{$member['id']});
})
function checkform(){
    var username = $.trim($("#t_username").val());
    var tel = $.trim($("#t_tel").val());
    var password = $.trim($("#t_password").val());
    var repassword = $.trim($("#t_repassword").val());
    if(username==''){
      alert('账户名称不能为空！');$("#t_username").focus();return false;
    }
    if(password!=repassword){
      alert('两次密码不同！');$("#t_password").focus();return false;
    }
    return true;
}
$(document).ready(function(){
  $("#fileid").change(function(){
    var form=document.getElementById("jizhiform");
    var data =new FormData(form);
    $.ajax({
       url: "{fun U('common/uploads')}",//处理图片的文件路径
       type: "POST",//传输方式
       data: data,
       dataType:"json",   //返回格式为json
       processData: false,  // 告诉jQuery不要去处理发送的数据
       contentType: false,   // 告诉jQuery不要去设置Content-Type请求头
       success: function(response){
        
        if(response.code==0){
          
          var result = '';
          result +='<img src="' + response['url'] + '" height="100"  />';
          //$("#fileid").hide();
         // $("#upload_ok").show();
          $('.view_img').html(result);
          $("#fileurl").val(response['url']);
        }else{
          alert(response.error);
        }
        
       }
    });
    
  });

  
});
</script>
</body>
</html>